package com.wbt.bambootown.ui.adapter;


import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.wbt.bambootown.R;
import com.wbt.bambootown.cons.Cons;
import com.wbt.bambootown.entity.CameraPic;
import com.wbt.bambootown.entity.Farms;
import com.wbt.bambootown.ui.view.recyclerview.BaseAdapter;
import com.wbt.bambootown.ui.view.recyclerview.BaseViewHolder;
import com.wbt.bambootown.utils.SPUtils;
import com.zhy.autolayout.utils.AutoUtils;


/**
 * Created by wufan on 2018/5/16.
 */

public class CameraPicAdapter extends BaseAdapter<CameraPic, BaseViewHolder>{

    private Context context;

    public CameraPicAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public BaseViewHolder createCustomViewHolder(ViewGroup parent, int viewType) {
        return new BaseViewHolder(parent , R.layout.item_camera_pic);
    }

    @Override
    public void bindCustomViewHolder(final BaseViewHolder viewHolder, final int position) {
        AutoUtils.autoSize(viewHolder.itemView);

        final CameraPic item = getItem(position);
        ImageView imageView = viewHolder.getImageView(R.id.iv_camera);
        TextView textView = viewHolder.getTextView(R.id.tv_time);
        textView.setText(item.getTime());
        Glide.with(context)
                .load("http://service.smartiot.cc:1183/" + item.getSrc())
                .placeholder(R.drawable.placeholder)
                .error(R.drawable.error)
                .into(imageView);

    }

    @Override
    public int getCustomViewType(int position) {
        return 0;
    }
}
